import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-10-02
 * Time: 12:56
 */
public class IODemon9 {
    public static void main(String[] args) throws IOException {
        try(InputStream inputStream = new FileInputStream("./test.txt")){

            while (true){
                //也可以一次读若干个字节,buffer(缓冲区)
                byte[] buffer = new byte[1024];//读的时候会尝试把buffer[1024]填满
                int n = inputStream.read(buffer);//传入的参数是buffer数组，方法内部对数组内容进行修改后，方法外部也能生效
                if (n == -1){
                    break;
                }
                for (int i = 0; i < n; i++) {
                    System.out.printf(" %x " ,buffer[i]);//遍历数组，并打印
                }

            }
        }
    }
}


